%!TEX root = 0.tex

\section{Building Utool} \label{sec:building}

So far, we have focused on how to use the complete Utool system as you
download it, unchanged. This is sufficient in many scenarios -- you
can access Utool from the command line, you can connect to it as a
server, and you can even implement your own Java classes that use our
classes directly and add new codecs, as long as you simply add \verb?Utool.jar? 
to your
classpath. But there may be a point at which you want to recompile
Utool. For such cases, we will now document how to unpack the Utool
source distribution and recompile it.

The Jar file \verb?Utool-<version>.jar? which you probably downloaded
from the website only contains the compiled class files that are
necessary for running the programme. This is the standard distribution
because it is pretty small, and thus downloads and loads quickly.

If you want to recompile (parts of) Utool, you will need to download
the source distribution. The source distribution has a filename of the
form \verb?Utool-src-<version>.jar?, and is some 4 megabytes in
size. In addition to the Utool classes, it contains the source code of
Utool, all classes of the iText, JGraphT, JGraph, and Getopt libraries
that we use, and the javacc and testng Jars that are used in compiling
Utool. The files in the source distribution Jar are in exactly the
same locations as in the ordinary Jar, so in particular you can use
the command \verb?java -jar Utool-src-<version>.jar? to run Utool. In
addition, you need the Java JDK 5.0 or higher, and you need Apache Ant
1.6 or higher.

Recompilation of Utool from the source distribution proceeds as
follows:

\begin{enumerate}
\item Unpack the Jar file in a new directory:
\begin{verbatim}
$ jar xf Utool-src-<version>.jar
\end{verbatim}
%$

\item Prepare for compiling by moving all files to the directories
where the build script expects them:
\begin{verbatim}
$ ant prepare
\end{verbatim}
%$

\item Change or add classes as you like. The source code of all
classes is under the directory \verb?src?. If you add new classes, you
may have to edit the Ant build script in \url{build.xml}.

\item Recompile as follows:
\begin{verbatim}
$ ant
\end{verbatim}
%$

This will create the file \verb?Utool-<version>.jar? in the directory
\verb?build/lib?, which you can run using \verb?java -jar?  as before.

%\item If you have access to the Jakarta BCEL library (we use
%version 5.1), you can add this library to your classpath and run

%\begin{verbatim}
%$ ant utool-compact
%\end{verbatim}
%$

%to build the (smaller) file \verb?build/lib/Utool-<version>.jar?
%which constitutes the main Utool distribution.
\end{enumerate}






%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "0"
%%% TeX-command-default: "LaTeX"
%%% End: 
